package com.woniuxy.hrp.mapper;

import com.woniuxy.hrp.entity.Medicine;
import com.woniuxy.hrp.provider.MedicineSqlProvider;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * @program: hrph
 * @InterfaceName MedicineMapper
 * @description:药物DAO
 * @author: WY
 **/
public interface MedicineMapper {
    //查询所有药物
    @Select("select *from hrp_medicine")
    List<Medicine> findAll();

    //根据id查询药物
    @Select("select *from hrp_medicine where id=#{id}")
    Medicine findById(int id);

    //增加药物
    @Insert("insert into hrp_medicine values (null,#{name},#{fee},#{description},#{number})")
    void insert(Medicine medicine);

    //删除药物
    @Delete("delete from hrp_medicine where id=#{id}")
    void del(int id);

    //修改药物
    @UpdateProvider(type = MedicineSqlProvider.class,method = "updateMedByCondition")
    void update(Medicine medicine);

    @Select("select * from hrp_medicine where id = #{id}")
    Medicine getById(int id);
}
